<!--#
 @version 0.3 (auto-set)
#-->
&nbsp;
<table border="0" align="center">
 <form action="?" method="get">
 <tr>
  <td valign="top">Title/Code:</td>
  <td valign="top"><input type="text" name="code" value="[#CODE#]" id="code_new"></td>
  <td valign="top"><input type="submit" name="submit" value="Continue"></td>
 </tr>
 <input type="hidden" name="category_id" value="<#CATEGORY_ID#>">
 <input type="hidden" name="shopping" value="<#SHOPPING#>">
 </form>
 <script language="javascript">
  var elem=document.getElementById('code_new');
  elem.focus();
 </script>
</table>

[#if CODE!=""#]
<table border="0" align="center">
 <tr>
  <td valign="top">
   <h1>Продукт</h1>
   <div id="op_new">
    <form action="?" method="get" name="frmEdit">
     <table width="100%" border="0">
      <tr>
       <td valign="top"><#LANG_TITLE#>:</td>
       <script language="javascript">
        function titleChanged(value) {
         // var s=new string;
         return false;
        }
       </script>
       <td valign="top"><input type="text" name="title" value="[#TITLE#]" id="title_product" onKeyUp="titleChanged(this.value);">
       [#if PRODUCT_ID#](ID: [#PRODUCT_ID#])[#else#](new)[#endif#]
       [#if CODE_TITLE!=""#]<br><a href="#" onClick="var elem=document.getElementById('title_product');elem.value='[#CODE_TITLE_HTML#]';return false;">[#CODE_TITLE#]</a>[#endif#]
       <div id="title_suggestions">[#if SUGGESTIONS#]
        [#begin SUGGESTIONS#]
        <a href="?category_id=<#CATEGORY_ID#>&code=[#TITLE#]" onClick="var elem=document.getElementById('title_product');elem.value='[#TITLE_HTML#]';return true;">[#TITLE#]</a><br>
        [#end SUGGESTIONS#]
       [#endif#]</div>
       </td>
      </tr>
      <tr>
       <td valign="top">SKU/Bar-code:</td>
       <td valign="top"><input type="text" name="code" value="[#CODE#]"></td>
      </tr>
      <tr>
       <td valign="top">Category:</td>
       <td valign="top"><select name="category_id">
        <option value="0">n/a
        [#begin CATEGORIES#]
        <option value="[#ID#]"[#if ID="<#CATEGORY_ID#>"#] selected[#endif#]>[#TITLE#]
        [#end CATEGORIES#]
       </select>
       <a href="#" onClick="var elem=document.getElementById('new_category');elem.style.display='block';return false;"><#LANG_ADD#></a>
       <div id="new_category" style="display:none">
       <input type="text" name="new_category" value="">
       </div>
       </td>
      </tr>
      <tr>
       <td valign="top"><#LANG_QUANTITY#>:</td>
       <td valign="top">
       <script language="javascript">
       function changeInputQty(id, val) {
        var elem=document.getElementById(id);
        var new_val=parseInt(elem.value);
        new_val+=val;
        elem.value=new_val;
        return false;
       }      
       </script>
       <a href="#" onClick="return changeInputQty('qty', -1);">-</a>
       <input type="text" id="qty" name="qty" value="[#QTY#]" size="10">
       <a href="#" onClick="return changeInputQty('qty', 1);">+</a>
       <input type="checkbox" name="qty_total" value="1"> <#LANG_TOTAL#>
       (<a href="#" onClick="var elem=document.getElementById('qty');elem.value='-1';return false;">---</a>)
       </td>
      </tr>
      <tr>
       <td valign="top"><#LANG_EXPIRE_IN#>:</td>
       <td valign="top">
       <a href="#" onClick="return changeInputQty('expire_days', -1);">-</a>
       <input type="text" name="expire_days" value="[#EXPIRE#]" size="10" id="expire_days"> 
       <a href="#" onClick="return changeInputQty('expire_days', 1);">+</a>
       (<#LANG_DAYS#>)
       </td>
      </tr>
      <tr>
       <td valign="top">&nbsp;</td>
       <td valign="top"><input type="text" name="expire_date" value="[#EXPIRE_DATE#]" maxlength=10 size=12>
  [#module name="dateselect" field="expire_date" form="frmEdit"#]</td>
      </tr>
      <tr>
       <td valign="top">&nbsp;</td>
       <td valign="top"><input type="submit" name="submit" value="<#LANG_ADD#>"></td>
      </tr>
     </table>
     <input type="hidden" name="mode" value="add_product">
     <input type="hidden" name="product_id" value="<#PRODUCT_ID#>">
     <input type="hidden" name="code_title" value="[#CODE_TITLE#]">
     <input type="hidden" name="shopping" value="<#SHOPPING#>">
    </form>
   </div>
  </td>
 </tr>
</table>
 <script language="javascript">
  var elem=document.getElementById('title_product');
  elem.focus();
 </script>
[#endif#]

<!--#
<p align=center>
<b>
<a href="?view_mode=edit_products&data_source=<#DATA_SOURCE#>">Add New</a>
</b>
</p>
#-->
<hr size="1">
<table border="0" align="center">
 <tr>

  <td valign="top">
   [#if !CATS#]<a href="?">[#endif#]<#LANG_CATEGORIES#></a>
   //
   <nobr>[#if ALL!=""#][#else#]<a href="?all=1">[#endif#]<#LANG_ALL_PRODUCTS#></a></nobr>
   //
   [#if EXPIRED!=""#][#else#]<a href="?expired=1">[#endif#]<#LANG_EXPIRED#></a>
   //
   [#if MISSING!=""#][#else#]<a href="?missing=1">[#endif#]<#LANG_MISSING#></a>
   //
   [#if SHOPPING!=""#][#else#]<a href="?shopping=1">[#endif#]<#LANG_SHOPPING_LIST#></a>
  </td>
 </tr>
</table>

<table border=0 align="center"><tr>
<td valign=top>
<!-- results -->
[#if RESULT#]

<script language="javascript">
 function changeQtyProcessed(id, data) {
  var elem=document.getElementById('product'+id+'_qty');
  elem.innerHTML=data;
  return false;
 }
 function changeQty(type, id) {
  var url="?ajax=1";
  url+='&op='+type+'&id='+id;
  AJAXRequest(url, 'changeQtyProcessed', id)
  return false;
 }

 function addToCart_processed(id, data) {
  var elem1=document.getElementById('product_'+id+'_incart');
  var elem2=document.getElementById('product_'+id+'_addcart');
  elem1.style.display='block';
  elem2.style.display='none';
  return false;
 }
 function addToCart(id) {
  var url="?ajax=1";
  url+='&op=addtocart&id='+id;
  AJAXRequest(url, 'addToCart_processed', id)
  return false;
 }

 function removeFromCart_processed(id, data) {
  var elem1=document.getElementById('product_'+id+'_incart');
  var elem2=document.getElementById('product_'+id+'_addcart');
  elem1.style.display='none';
  elem2.style.display='block';
  return false;
 }
 function removeFromCart(id) {
  var url="?ajax=1";
  url+='&op=removefromcart&id='+id;
  AJAXRequest(url, 'removeFromCart_processed', id)
  return false;
 }

 function inCart_processed(id, data) {
  var elem1=document.getElementById('product_'+id+'_ok');
  var elem2=document.getElementById('product_'+id+'_notok');
  elem1.style.display='block';
  elem2.style.display='none';
  var url="?shopping=1";
  window.location=url;
  return false;
 }
 function inCart(id) {
  var url="?ajax=1";
  url+='&op=incart&id='+id;
  AJAXRequest(url, 'inCart_processed', id)
  return false;
 }

 function notInCart_processed(id, data) {
  var elem1=document.getElementById('product_'+id+'_ok');
  var elem2=document.getElementById('product_'+id+'_notok');
  elem1.style.display='block';
  elem2.style.display='none';
  var url="?shopping=1";
  window.location=url;
  return false;
 }
 function notInCart(id) {
  var url="?ajax=1";
  url+='&op=notincart&id='+id;
  AJAXRequest(url, 'notInCart_processed', id)
  return false;
 }


</script>

<!-- search results (list) -->
[#if CATS#]
<div id="all_categories">
<ul>
 [#begin CATS#]
 <li><a href="?category_id=[#ID#]">[#TITLE#][#if TOTAL!="0"#] ([#TOTAL#])[#endif#]</a>
 [#if CATS#]<ul>[#tree CATS#]</ul>[#endif CATS#]
 </li>
 [#end CATS#]
</ul>
</div>
[#else CATS#]


<div id="category_0">
<table border="0" cellpadding="5">
[#begin RESULT#]
[#if NEW_CATEGORY#]
</table>
</div>
<div id="category_[#CATEGORY_ID#]">
<h1>[#CATEGORY_TITLE#]</h1>
<table border="0" cellpadding="5">
[#endif NEW_CATEGORY#]
<tr>
 [#if "<#SHOPPING#>"=="1"#]
 <td>
 <div id="product_[#ID#]_ok"[#if IN_CART!="1"#] style="display:none"[#endif#]>
 <a href="#" onClick="return notInCart([#ID#]);"><img src="/img/btn/ok.png" border="0"></a>
 </div>
 <div id="product_[#ID#]_notok"[#if IN_CART="1"#] style="display:none"[#endif#]>
 <a href="#" onClick="return inCart([#ID#]);"><img src="/img/btn/notok.png" border="0"></a>
 </td>
 [#endif#]
 <td  width="85%">
  <a href="?data_source=<#DATA_SOURCE#>&view_mode=edit_products&id=[#ID#]"><b>[#TITLE#]</b></a>
  [#if EXPIRE_TERM!="" && QTY!="0"#]
   <div>Will expire in [#EXPIRE_TERM#] days [#if EXPIRED#]<b style="color:red"><#LANG_EXPIRED#></b>[#endif EXPIRED#]</div>
  [#endif#]
  [#if RECOMMENDED#]
   <div><#RECOMENDED_QUANTITY#>: [#RECOMMENDED#]</div>
  [#endif#]
 </td>
 <td><a href="#" onClick='return changeQty("minus", "[#ID#]")'><img src="/img/btn/minus.png" border="0"></a></td>
 <td align=center width="5%">
  <span id="product[#ID#]_qty">[#QTY#]</span>
 </td>
 <td><a href="#" onClick='return changeQty("plus", "[#ID#]")'><img src="/img/btn/plus.png" border="0"></a></td>
 <td>
 <div id="product_[#ID#]_incart"[#if INCART!="1"#] style="display:none"[#endif#]>
 <a href="#" onClick="return removeFromCart([#ID#]);"><img src="/img/btn/incart.png" border="0"></a>
 </div>
 <div id="product_[#ID#]_addcart"[#if INCART="1"#] style="display:none"[#endif#]>
 <a href="#" onClick="return addToCart([#ID#]);"><img src="/img/btn/nocart.png" border="0"></a>
 </div>
 </td>
</tr>
[#end RESULT#]
</table>

&nbsp;
<table border="0">
 <tr>
  [#if PREV_CATEGORY_ID#]
  <td valign="top">&lt;&lt;&lt; <a href="?category_id=[#PREV_CATEGORY_ID#]">[#PREV_CATEGORY_TITLE#]</a></td>
  [#endif#]
  <td valign="top">&nbsp;&nbsp;&nbsp;</td>
  [#if NEXT_CATEGORY_ID#]
  <td valign="top"><a href="?category_id=[#NEXT_CATEGORY_ID#]">[#NEXT_CATEGORY_TITLE#]</a> &gt;&gt;&gt;</td>
  [#endif#]
 </tr>
</table>

<!-- / search results (list) -->
<!-- paging -->
<!-- / paging -->
[#else RESULT#]
<p align=center>
<font color="red"><#LANG_NO_RECORDS_FOUND#></font>
</p>
[#endif RESULT#]




<!-- / results -->
</td></tr></table>
[#endif CATS#]
